<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Arr;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    /**
     * @param int $code
     * @param string $data
     * @param string $msg
     * @return array
     */

    const SUCCESS_CODE = 0;
    const FAILED_CODE = 500;

    protected $msgMap = [
        self::SUCCESS_CODE   => 'SUCCESS',
        self::FAILED_CODE    => 'FAILED'
    ];


    public function ret($code, $data = '', $msg = '')
    {
        $msg = $msg ?: Arr::get($this->msgMap, $code);

        return compact('code', 'data', 'msg');
    }
}
